package com.ruoyi.web.controller.dangerControl;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.ruoyi.dangerControl.vo.HdProcessVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dangerControl.domain.HdProcessRecord;
import com.ruoyi.dangerControl.service.IHdProcessRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 隐患-过程管理流转记录Controller
 *
 * @author lth
 * @date 2023-12-15
 */
@RestController
@RequestMapping("/dangerControl/record")
public class HdProcessRecordController extends BaseController
{
    @Autowired
    private IHdProcessRecordService hdProcessRecordService;

    /**
     * 查询隐患-过程管理流转记录列表
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(HdProcessRecord hdProcessRecord)
    {
        startPage();
        List<HdProcessRecord> list = hdProcessRecordService.selectHdProcessRecordList(hdProcessRecord);
        return getDataTable(list);
    }

    /**
     * 导出隐患-过程管理流转记录列表
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:record:export')")
    @Log(title = "隐患-过程管理流转记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HdProcessRecord hdProcessRecord)
    {
        List<HdProcessRecord> list = hdProcessRecordService.selectHdProcessRecordList(hdProcessRecord);
        ExcelUtil<HdProcessRecord> util = new ExcelUtil<HdProcessRecord>(HdProcessRecord.class);
        util.exportExcel(response, list, "隐患-过程管理流转记录数据");
    }

    /**
     * 获取隐患-过程管理流转记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hdProcessRecordService.selectHdProcessRecordById(id));
    }

    /**
     * 新增隐患-过程管理流转记录
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:record:add')")
    @Log(title = "隐患-过程管理流转记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HdProcessRecord hdProcessRecord)
    {
        return toAjax(hdProcessRecordService.insertHdProcessRecord(hdProcessRecord));
    }

    /**
     * 修改隐患-过程管理流转记录
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:record:edit')")
    @Log(title = "隐患-过程管理流转记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HdProcessRecord hdProcessRecord)
    {
        return toAjax(hdProcessRecordService.updateHdProcessRecord(hdProcessRecord));
    }

    /**
     * 删除隐患-过程管理流转记录
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:record:remove')")
    @Log(title = "隐患-过程管理流转记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hdProcessRecordService.deleteHdProcessRecordByIds(ids));
    }

    /**
     * 流转记录列表
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:process:list')")
    @GetMapping("/operatePageList")
    public TableDataInfo operatePageList(@RequestBody HdProcessVo vo){
        PageHelper.startPage(vo.getPageNum(),vo.getPageSize());
        List<HdProcessRecord> list = hdProcessRecordService.operatePageList(vo);
        return getDataTable(list);
    }




}
